package com.lglbc.server;

import com.lglbc.hello.Mode;
import com.lglbc.hello.OpenAPIGrpc;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.stub.StreamObserver;

public class Client {
    public static void main(String[] args) {
        ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 9090)
                .usePlaintext()
                .build();

        OpenAPIGrpc.OpenAPIBlockingStub stub = OpenAPIGrpc.newBlockingStub(channel);

        Mode.Request request = Mode.Request.newBuilder()
                .setName("乐哥聊编程")
                .build();

        stub.serverStreaming(request)
                .forEachRemaining(response -> {
                    System.out.println("Received response: " + response.getMessage());
                });

        channel.shutdown();
    }

}
